/**
 * 类型检查
 * @param target 目标
 * @returns
 */
function type(target: any): string {
  const ret = typeof target;
  const temp = {
    "[object Array]": "array",
    "[object Object]": "object",
    "[object Function]": "function",
    "[object String]": "string-object",
    "[object Number]": "number-object",
    "[object Boolean]": "boolean-object",
    "[object Date]": "date",
    "[object RegExp]": "regexp",
    "[object Error]": "error",
    "[object HTMLDocument]": "document",
  };
  if (target === null) {
    return "null";
  } else if (ret === "object") {
    const str = Object.prototype.toString.call(target);
    return temp[str];
  } else {
    return ret;
  }
}

function unique<T>(array: T[]) {
  let arr: T[] = [];
  for (let i = 0, len = array.length; i < len; i++) {
    if (!arr.includes(array[i])) {
      arr.push(array[i]);
    }
  }
  return arr;
}
